package com.yiwei.ydd.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yiwei.ydd.R;
import com.yiwei.ydd.api.model.VipComboRecordModel;
import com.yiwei.ydd.util.DateTime;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by xsooy-pc on 2017/10/23.
 */

public class VipUpRecordAdapter extends ItemAdapter<VipComboRecordModel.DatasBean.ListBean, VipUpRecordAdapter.DefaultHolder> {


    public VipUpRecordAdapter(Context context) {
        super(context);
    }

    @Override
    public DefaultHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DefaultHolder(inflate(R.layout.item_level_up_recored, parent));
    }

    @Override
    public void onBindViewHolder(DefaultHolder holder, int position) {
        VipComboRecordModel.DatasBean.ListBean item = getItem(position);
        holder.txtTitle.setText(item.description);
        holder.txtMoney.setText(item.money);
        if (!TextUtils.isEmpty(item.created_at)) {
            holder.txtTime.setText(DateTime.toDateTime(Long.valueOf(item.created_at) * 1000));
        } else {
            holder.txtTime.setText("");
        }

    }

    class DefaultHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_title)
        TextView txtTitle;
        @BindView(R.id.txt_time)
        TextView txtTime;
        @BindView(R.id.txt_money)
        TextView txtMoney;

        public DefaultHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
